package com.tiancheng.trade.merchant.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.tiancheng.trade.commom.core.data.PageInfo;
import com.tiancheng.trade.commom.core.data.Result;
import com.tiancheng.trade.commom.web.model.request.QueryOrderMerchantReqVO;
import com.tiancheng.trade.commom.web.model.response.QueryOrderMerchantResVO;
import com.tiancheng.trade.merchant.dto.responsedto.MerchantWithChannelDTO;
import com.tiancheng.trade.merchant.exception.BusinessException;
import com.tiancheng.trade.merchant.model.Merchant;
import com.tiancheng.trade.merchant.model.MerchantPaymentChannel;
import com.tiancheng.trade.merchant.vo.merchant.*;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;

public interface IMerchantService extends IService<Merchant> {

    /**
     * 根据ID查询
     *
     * @param id
     * @return
     */
    Merchant findById(Long id) throws BusinessException;

    /**
     * 商户信息查询列表
     *
     * @param merchantVO
     * @return
     */
    PageInfo<Merchant> getMerchantPage(GetPageMerchantVO merchantVO) throws BusinessException;

    List<Merchant> findList(GetMerchantVO merchantVO) throws BusinessException;

    Merchant findMerchant(GetMerchantVO merchantVO) throws BusinessException;

    Merchant findMerchantOrg(GetPageMerchantVO merchantVO) throws BusinessException;

    int add(Merchant merchant) throws BusinessException;

    int update(Merchant merchant) throws BusinessException;


    int remove(Long id) throws BusinessException;

    /**
     * 商户信息导出
     *
     * @param merchantVO
     * @param request
     * @param response
     * @throws IOException
     */
    void export(GetPageMerchantVO merchantVO, HttpServletRequest request, HttpServletResponse response) throws IOException;

    /**
     * 按商户号批量查询商户信息
     *
     * @param merchantCodes
     * @return
     * @throws BusinessException
     */
    List<Merchant> getMerchantByMerCode(List<String> merchantCodes) throws BusinessException;

    /**
     * 按组织编号查询商户list信息
     *
     * @param merchantVO
     * @return
     * @throws BusinessException
     */
    List<Merchant> findMerchantByOrgCode(GetMerchantVO merchantVO) throws BusinessException;

    /**
     * 根据业务侧商户编号，查询商户信息
     *
     * @param channelVO
     * @return
     * @throws BusinessException
     */
    List<MerchantPaymentChannelVO> findMerchantByBusiness(MerchantPaymentChannelVO channelVO) throws BusinessException;

    /**
     * 根据商户名称模糊查询商户信息
     *
     * @param merchantName
     * @return
     * @throws BusinessException
     */
    List<GetMerchantVO> getMerchantsByName(String merchantName) throws BusinessException;

    /**
     * 根据商户编码和支付渠道编码查询商户信息（批量）
     *
     * @param list
     */
    List<MerchantWithChannelDTO> listByMerchantCodeAndChannel(List<GetMerchantPaymentVO> list);

    List<MerchantPaymentChannel> getMerchantPaymentChannelByMerchantCode(String merchantCode);

    List<AllMerchantResVo> findOnlyMerchantList(GetMerchantVO merchantVO);

    /**
     * 根据交易中台 商户编号 商户信息和支付渠道信息
     *
     * @param list {@link List}<{@link String}> 交易中台商品编号列表
     * @return {@link List}<{@link MerchantPaymentChannelVO}> 商品和支付渠道信息列表
     */
    List<MerchantPaymentChannelVO> findPaymentChannelByMerchantCodes(List<String> list);

    List<CommonMerchantVO> getMerchantByCreateDate(LocalDate createDate);

    /**
     * 查询下单商户信息
     * @param queryOrderMerchantReqVO
     * @return
     */
    List<QueryOrderMerchantResVO> queryOrderMerchant(QueryOrderMerchantReqVO queryOrderMerchantReqVO);
}
